import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: yang
 * Date: 2022-04-24
 * Time: 17:09
 */
public class GCD {
    public static int gcd(int a, int b){
        return b==0?a:gcd(b,a % b);
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if(a > b){
            System.out.println(gcd(a,b));
        }
        else{
            System.out.println(gcd(b,a));
        }
    }
}
